package com.qfedu.anon;

import com.qfedu.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 注解的方式（操作有限，不如xml文件）
 */
public interface DeptMapper {
    @Insert("insert into DEPT(NAME) values(#{name})")
    @Options(useGeneratedKeys = true,keyColumn = "ID",keyProperty = "id")//返回数据库中该条数据的ID到dept里面
    void addDept(Dept dept);

    @Update("update DEPT set NAME=#{name} where ID=#{id}")
    void updateDept(Dept dept);

    @Delete("delete from DEPT where ID=#{id}")
    void delete(Integer id);

    @Select("select ID,NAME from DEPT")
    List<Dept> getDeptList();

    @Select("select ID,NAME from DEPT where ID=#{id}")
    List<Dept> getDepById(Integer id);

}
